import { RouteRecordRaw } from "vue-router";
import NoAuth from "@/views/NoAuthView.vue";
import MdView from "@/views/MdView.vue";
import ACCESS_ENUM from "../access/accessEnum";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegistryView from "@/views/user/UserRegistryView.vue";
import BasicLayout from "@/layouts/BasicLayout.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import QuestionCreateView from "@/views/question/QuestionCreateView.vue";
import QuestionControlView from "@/views/question/QuestionControlView.vue";
import QuestionView from "@/views/question/QuestionView.vue";
import QuestionShowView from "@/views/question/QuestionShowView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/question/show",
    name: "题目",
    component: QuestionShowView,
    meta: {
      layout: BasicLayout,
    },
  },
  {
    path: "/",
    name: "home",
    component: QuestionShowView,
    meta: {
      hideInMenu: true,
      layout: BasicLayout,
    },
  },

  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuth,
    meta: {
      hideInMenu: true,
      layout: BasicLayout,
    },
  },
  {
    path: "/md",
    name: "md编辑器",
    component: MdView,
    meta: {
      hideInMenu: true,
      layout: BasicLayout,
    },
  },

  {
    path: "/question/create",
    name: "创建题目",
    component: QuestionCreateView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      layout: BasicLayout,
    },
  },
  {
    path: "/question/update",
    name: "修改题目",
    component: QuestionCreateView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      layout: BasicLayout,
      hideInMenu: true,
    },
  },
  {
    path: "/question/control",
    name: "管理题目",
    component: QuestionControlView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      layout: BasicLayout,
    },
  },
  {
    path: "/question/view/:id",
    name: "查看题目",
    component: QuestionView,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
      layout: BasicLayout,
    },
  },
  {
    path: "/user",
    name: "登陆",
    meta: {
      layout: UserLayout,
      hideInMenu: true,
    },
    children: [
      {
        path: "login",
        name: "登陆",
        component: UserLoginView,
        meta: {
          layout: BasicLayout,
          hideInMenu: true,
        },
      },
      {
        path: "registry",
        name: "注册",
        component: UserRegistryView,
        meta: {
          layout: BasicLayout,
          hideInMenu: true,
        },
      },
    ],
  },
];
